package admin.hakgwa.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.hakgwa.domain.HakgwaCommand;

@Component
public class HakgwaDaoImpl extends SqlSessionDaoSupport implements HakgwaDao{

	@Override
	public List<HakgwaCommand> getHakgwalist() {
		
		List<HakgwaCommand> list = getSqlSession().selectList("getHakgwalist");
				
		return list;
	}

	@Override
	public HakgwaCommand getHakgwa(String id) {
		HakgwaCommand Hakgwa = getSqlSession().selectOne("getHakgwa",id);
		return Hakgwa;
	}
	
	@Override
	public String getHakgwaName(String code){
		String hakgwaName = "";
		hakgwaName = getSqlSession().selectOne("getHakgwaName",code);
		return hakgwaName;
	}

	@Override
	public List<HakgwaCommand> list(Map<String, Object> map) {
		List<HakgwaCommand> list = getSqlSession().selectList("HakgwaList",map);
		return list;
	}
	
	@Override
	public List<HakgwaCommand> list() {
		List<HakgwaCommand> list = getSqlSession().selectList("HakgwaList");
		return list;
	}

	@Transactional
	@Override
	public void insert(HakgwaCommand Hakgwa) {
		getSqlSession().insert("insertHakgwa",Hakgwa);
	}

	@Override
	public HakgwaCommand selectHakgwa(String code) {
		HakgwaCommand command = (HakgwaCommand)getSqlSession().selectOne("selectHakgwa",code);
		return command;
	}

	@Transactional
	@Override
	public void delete(String code) {
		getSqlSession().delete("deleteHakgwa",code);
	}

	@Override
	public Integer HakgwaDup(String code) {
		return getSqlSession().selectOne("HakgwaCount",code);
	}
	
	@Transactional
	@Override
	public void update(HakgwaCommand Hakgwa) {
		getSqlSession().update("updateHakgwa",Hakgwa);
	}
	
}
